Function package:~/transbot_ws/src/transbot_laser
Introduction of lidar obstacle avoidance:
-Set lidar detection angle and response distance -After turning on the trolley, the trolley drives in a straight line without obstacles
-Determine the direction of obstacles appearing in the car (front left, front right, straight ahead) -Respond to the position of the obstacle in the car (turn left, turn right, turn left in a big circle, turn right in a big circle)
Start up
roslaunch transbot_laser laser_Avoidance.launch
Dynamic debugging parameters
xxxxxxxxxx
rosrun rqt_reconfigure rqt_reconfigure
Parameter analysis:
Parameter | Range | Analysis |
---|---|---|
【linear】 | 【0.0,0.45】 | Linear speed of robot |
【angular】 | 【0.0,2.0】 | Angular speed of robot |
【LaserAngle】 | 【10,180】 | Lidar detection angle (angle of left and right side) |
【ResponseDist】 | 【0.0,8.0】 | Robot response distance |
【switch】 | 【False,True】 | Robot movement【start/pause】 |
[Switch] Click the box in front of [switch], the value of [switch] is True, and the car will stop. [Switch] The default is False, and the car moves.
View node
xxxxxxxxxx
rqt_graph
launch file
x
<launch>
<!-- Start the lidar node-->
<include file="$(find rplidar_ros)/launch/rplidar.launch"/>
<!-- Dynamic debugging tool node -->
<!-- <node pkg="rqt_reconfigure" type="rqt_reconfigure" name="rqt_reconfigure" output="screen"/>-->
<!-- Start the car chassis drive node-->
<node pkg="transbot_bringup" type="transbot_driver.py" name="transbot_node" required="true" output="screen">
<param name="imu" value="/transbot/imu"/>
<param name="vel" value="/transbot/get_vel"/>
</node>
<!-- Handle control node -->
<include file="$(find transbot_ctrl)/launch/transbot_joy.launch"/>
</launch>
x
<launch>
<!-- Start base.launch file-->
<include file="$(find transbot_laser)/launch/base.launch"/>
<!-- Start the lidar obstacle avoidance node -->
<node name='laser_Avoidance' pkg="transbot_laser" type="laser_Avoidance.py" required="true" output="screen"/>
</launch>
py code:~/transbot_ws/src/transbot_laser/scripts/laser_Avoidance.py
xxxxxxxxxx
if self.front_warning > 10 and self.Left_warning > 10 and self.Right_warning > 10:
# print ('1、turn right')
... ...
elif self.front_warning > 10 and self.Left_warning <= 10 and self.Right_warning > 10:
# print ('2、turn left')
... ...
if self.Left_warning > 10 and self.Right_warning <= 10:
# print ('3、turn right')
... ...
elif self.front_warning > 10 and self.Left_warning > 10 and self.Right_warning <= 10:
# print ('4、turn right')
... ...
if self.Right_warning <= 10 and self.Left_warning > 10:
# print ('5、turn left')
... ...
elif self.front_warning > 10 and self.Left_warning < 10 and self.Right_warning < 10:
# print ('6、turn right')
... ...
elif self.front_warning < 10 and self.Left_warning > 10 and self.Right_warning > 10:
# print ('7、turn right')
... ...
elif self.front_warning < 10 and self.Left_warning > 10 and self.Right_warning <= 10:
# print ('8、turn right')
... ...
elif self.front_warning < 10 and self.Left_warning <= 10 and self.Right_warning > 10:
# print ('9、turn left')
... ...
else:
# print ('10、advance')
... ...
According to the obstacle, the position of appearance, set up the different state of the trolley.
Source code parameter analysis:
Parameter | Defaults value | Judgment |
---|---|---|
self.front_warning | Defaults is 0 | When the value is greater than 10, there is an obstacle ahead. |
self.Left_warning | Defaults is 0 | When the value is greater than 10, there is an obstacle in the front left. |
self.Right_warning | Defaults is 0 | When the value is greater than 10, there is an obstacle in the front right. |